import wmcRequest from '@/render/service'
import { IDataType } from '../types'
export function newProject(project: any): any {
  return wmcRequest.post<IDataType>({
    url: '/projects',
    data: project
  })
}
export function deleteProject(name: string): any {
  return wmcRequest.delete({
    url: `/projects/${name}`
  })
}

export function getAllProjects(): any {
  return wmcRequest.get({
    url: '/projects'
  })
}

export function updateProjectModules(
  projectName: string,
  addModuleIds: string,
  deleteModuleIds: string
): any {
  return wmcRequest.patch({
    url: `/projectModules?projectName=${projectName}&addModuleIds=${addModuleIds}&deleteModuleIds=${deleteModuleIds}`
  })
}

export function deleteProjectModule(
  projectName: string,
  projectModuleName: string
): any {
  console.log(projectName, projectModuleName)
  return wmcRequest.delete({
    url: `/projectModules/${projectName}/${projectModuleName}`
  })
}

export function getProjectModules(projectName: string): any {
  return wmcRequest.get({
    url: `/projectModules?projectName=${projectName}`
  })
}
